package com.dl.study.module.user.controller;


import com.dl.study.module.user.domain.dto.UserLoginDTO;
import com.dl.study.module.user.service.UserService;

import com.sca.core.common.domain.ResponseDTO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: user
 * @Date: 2021/10/21 17:09
 * @Description:
 */
@RestController
@RefreshScope
@Slf4j
public class UserController extends BaseController {

    @Autowired
    private UserService userService;

  //  @Value("${constomer.username}")
    private String userName;

    @GetMapping("/demo")
    public String demo() {
        return "demo ok！！！" + userName;
    }

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public ResponseDTO<Object> login(@RequestBody UserLoginDTO userLoginDTO, HttpServletResponse response) {
        return userService.login(userLoginDTO, response);
    }

    /**
     * 退出
     *
     * @author dl
     * @date 2021/10/27
     */
    @GetMapping("/logout")
    public ResponseDTO<Object> logout(HttpServletRequest request) {
        return userService.logout(request);
    }

    /**
     * 包装箱库存-导出
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "测试导出", notes = "@author lxl")
    @GetMapping("/testExport")
    public ResponseEntity<byte[]> downloadPackingBoxStatistics( HttpServletRequest request) {
//        ExportExcelUtil<UserExportVo, UserExportVo, UserExportVo> exportExcelUtil = new ExportExcelUtil<>(UserExportVo.class);
//        List<UserExportVo>list=new ArrayList<>();
//        list.add(new UserExportVo("名称1","名称1"));
//        list.add(new UserExportVo("名称1","名称1"));
//        list.add(new UserExportVo("名称1","名称1"));
//        list.add(new UserExportVo("名称1","名称1"));
//        list.add(new UserExportVo("名称1","名称1"));
//        list.add(new UserExportVo("名称1","名称1"));
//        return exportExcelUtil.exportExcel("环境1", list, "明恒", request);
        return null;
    }
}
